package cn.tedu.jewelry.mapper;

import cn.tedu.jewelry.entity.Banner;
import cn.tedu.jewelry.vo.BannerStandVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

//轮播图模块
@Mapper
public interface BannerMapper {
    //添加轮播图
    @Result(column = "banner_name",property = "bannerName")
    @Insert("insert into banner values(null,#{bannerName},#{url},1)")
    void addBanner(String bannerName,String url);

    //获取轮播图列表
    @Result(column = "banner_name",property = "bannerName")
    @Select("select * from banner")
    List<BannerStandVO> getBannerList();

    //通过id获取轮播图
    @Result(column = "banner_name",property = "bannerName")
    @Select("select * from banner where id= #{id}")
    BannerStandVO getBannerById(Long id);

    //修改轮播图状态
    @Update("update banner set enable=#{enable} where id=#{id}")
    void updateBannerByIdAndEnable(Long id,Integer enable);

    //删除轮播图
    @Delete("delete from banner where id=#{id}")
    void deleteBannerById(Long id);
}
